#include "database.h"
#include <stdlib.h>
#include <string.h>
#include <string>
#include <iostream>

int main(int argc, char** argv) {
	using namespace std;
	using namespace client_server;
	Database db;
	cout << "Creating newsgroup" << endl;
	db.create_newsgroup("newsgroup");
	
	vector<std::pair<int, std::string> > list = db.list_newsgroups();
	cout << "Listing newsgroups" << endl;
	for(size_t i = 0; i < list.size(); ++i){
		cout << list[i].first << " - " << list[i].second << endl;
	}
	
	cout << "Creating article" << endl;
	db.create_article(1, "name", "author", "content");
	
	cout << "Listing articles" << endl;
	vector<pair<int, string> > NAMES = db.list_articles(1);
	for(size_t i = 0; i < NAMES.size(); ++i) {
		cout << NAMES[i].first << " - " << NAMES[i].second << endl;
	}
	
	cout << "Getting article" << endl;
	Article a = db.get_article(1, 0);
	cout << a.get_name() << endl;
	cout << a.get_author() << endl;
	cout << a.get_content() << endl;
	
	cout << "Deleting article" << endl;
	db.delete_article(1, 1);
	
	cout << "Listing articles" << endl;
	vector<pair<int, string> > NAMES2 = db.list_articles(1);
	for(size_t i = 0; i < NAMES2.size(); ++i) {
		cout << NAMES2[i].first << " - " << NAMES2[i].second << endl;
	}
	
	cout << "Deleting newsgroup" << endl;
	db.delete_newsgroup(1);
	
	
	vector<std::pair<int, std::string> > list2 = db.list_newsgroups();
	cout << "Listing newsgroups" << endl;
	for(size_t i = 0; i < list2.size(); ++i){
		cout << list2[i].first << " - " << list2[i].second << endl;
	}
	
	
}
